<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>佐心，教家长做父母</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" href="assets/css/amazeui.min.css">
    <link rel="stylesheet" href="assets/css/style.css?v=2.3">
    <link rel="stylesheet" href="assets/css/index.css?v=2.3">
    <link rel="stylesheet"  href="assets/css/menu.css?v=2.3">
    <link rel="stylesheet"  href="assets/css/service_market.css?v=2.3">
    <script>
    	var cityName_="";
    </script>
    <script>
    	    /** 
     * 返回前一页（或关闭本页面） 
     * <li>如果没有前一页历史，则直接关闭当前页面</li> 
     */  
    function goBack(){  
        if ((navigator.userAgent.indexOf('MSIE') >= 0) && (navigator.userAgent.indexOf('Opera') < 0)){ // IE  
            if(history.length > 0){  
                window.history.go( -1 );  
            }else{  
                location.href="${ctx}/index.jsp";
            }  
        }else{ //非IE浏览器  
            if (navigator.userAgent.indexOf('Firefox') >= 0 ||  
                navigator.userAgent.indexOf('Opera') >= 0 ||  
                navigator.userAgent.indexOf('Safari') >= 0 ||  
                navigator.userAgent.indexOf('Chrome') >= 0 ||  
                navigator.userAgent.indexOf('WebKit') >= 0){  
      
                if(window.history.length > 1){  
                    window.history.go( -1 );  
                }else{  
                    location.href="${ctx}/index.jsp";
                }  
            }else{ //未知的浏览器  
                window.history.go( -1 );  
            }  
        }  
    }  
    </script>
</head>
<body class="bg-gray">

<header data-am-widget="header" class="am-header am-header-default am-header-fixed">
    <div class="am-header-left am-header-nav">
        <a  onclick="goBack();"  >
            <i class="icon_8"></i>
        </a>
    </div>
    <h1 class="am-header-title margin-10s">
        <div class="search">
            <input type="search" id="txtsearch" placeholder="请输入关键字搜索">
            <!-- <i class="icon_14 am-hide"></i> -->
        </div>
    </h1>
    <div class="am-header-right am-header-nav">
        <a class="widht-10s">
            <i id="soso" class="icon_121"></i>
        </a>
    </div>

</header>

<section class="am-padding-bottom-sm am-padding-bottom-xl" id="amz-main" data-tag="css-nav">


    <div class="am-g  am-g-collapse expert_tabs bg-white am-text-center  padding-top-bottom-10 tab-fixed">
        <div class="am-u-sm-4 border-right"> <span  class="prelative padding-left-fu20px" onclick="$('#my-popup').modal('open')"><span id="span_city">城市</span><i class="am-icon-angle-down"></i>
        </span></div>
        <div class="am-u-sm-4 border-right"><a id="sort_date" class="prelative padding-left-fu20px">时间<span class="icon-sort"></span></a></div>
        <div class="am-u-sm-4"><a id="sort_price" class="prelative padding-left-fu20px">价格<span class="icon-sort"></span></a></div>
    </div>


    <!--列表-->
    <div class=" traincamp_list  margin-top-42">
        

    </div>

</section>
<footer data-am-widget="navbar" class="am-navbar am-cf am-navbar-default "
        id="">
    <ul class="am-navbar-nav am-cf am-avg-sm-4">
        <li>
            <a href="index.jsp">
                <img src="assets/images/icon/index/icon_home.png"
                     alt="首页"/>
                <span class="am-navbar-label">首页</span>
            </a>
        </li>
        <li>
            <a href="counseKu.jsp" class="">
                <img src="assets/images/icon/index/icon_zhuanjia.png"
                     alt="专家库"/>
                <span class="am-navbar-label">专家库</span>
            </a>
        </li>

        <li>
            <a href="peixun.jsp" class="selected">
                <img src="assets/images/icon/index/icon_peixun_on.png"
                     alt="培训"/>
                <span class="am-navbar-label">培训</span>
            </a>
        </li>
        <li>
            <a href="myzones.jsp" class="">
                <img src="assets/images/icon/index/icon_user.png"
                     alt="我的"/>
                <span class="am-navbar-label" onclick="goMe();">我的</span>
            </a>
        </li>
    </ul>
</footer>
<!--选择城市-->
<div class="am-popup" id="my-popup">
    <div class="am-popup-inner">

        <header data-am-widget="header" class="am-header am-header-default am-header-fixed ">
            <div class="am-header-left am-header-nav">
                <a class="" data-am-modal-close>
                    <!--更新-->
                    <i class="icon_8"></i>
                </a>
            </div>
            <h1 class="am-header-title">
                选择城市
            </h1>

        </header>

        <section class="" >
            <div class="">
                <ul class="list-group">
                    <li class="fis-filter-item letter"><a>当前</a> <i></i></li>
                    <li class="fis-filter-item "><a>${cityName}</a><span class="font-gray-1 font-14">（GPS定位）</span> <i></i></li>
                    <li class="fis-filter-item letter"><a>选择其他城市</a> <i></i></li>
                </ul>
                <ul class="list-group" id="cityList" data-node="city">
                    <li class="fis-filter-item selected" data-am-modal-close><a>苏州市</a> <i></i></li>
                    <li class="fis-filter-item " data-am-modal-close><a>福州市</a> <i></i></li>
                    <li class="fis-filter-item " data-am-modal-close><a>上海市</a> <i></i></li>
                    <li class="fis-filter-item " data-am-modal-close><a>深圳市</a> <i></i></li>
                </ul>


            </div>


        </section>
    </div>
</div>
<script src="assets/js/jquery.min.js"></script>
<script>
function goPeiDesc(id){
   location.href="gotoPeixunDesc?studyId="+id;
}
</script>
<script src="assets/js/amazeui.min.js"></script>
<script>
    $(function () {

		var cityLists=$.ajax({url:"getCityList",async:false});
        var cityList=JSON.parse(cityLists.responseText);
        if(cityList.resultCode=="0"){
        	var cityListHtml="";
        	   for(var i=0;i<cityList.cityNameList.length;i++){
	               cityListHtml+="<li class='fis-filter-item ' data-am-modal-close><a>"+cityList.cityNameList[i].cityName+"市</a> <i></i></li>";
               };
               $("#cityList").html(cityListHtml);
        }


		var counselorList=$.ajax({url:"getStudyList?studyType=2",async:false});
        var jsonCounselor=JSON.parse(counselorList.responseText);
        
        var html="";
        if(jsonCounselor.resultCode=="0"){
        	for(var i=0;i<jsonCounselor.studylist.length;i++){
				html+="<div class='traincamp_item bg-white am-padding-sm border-1 am-margin-bottom-sm'>";
			    html+="        <div class='box' onclick=goPeiDesc("+jsonCounselor.studylist[i].id+")>";
			    html+="            <div><img class='img-70-70' src='"+jsonCounselor.studylist[i].studyUrl+"'></div>";
			    html+="            <div class='box-1 am-padding-left-sm'>";
			    html+="                <div class='font-color-13 font-bold font-16 word-space-2' >"+jsonCounselor.studylist[i].studyTitle+"</div>";
			    html+="                <div class=''>";
			    html+="                    <ul class='am-pagination am-pagination-default' >";
			    if(null!=jsonCounselor.studylist[i].studyLabel && ""!=jsonCounselor.studylist[i].studyLabel){
			    	var studyLabel=jsonCounselor.studylist[i].studyLabel;
			    	var label=studyLabel.split(",");
			    	for(var j=0;j<label.length;j++){
			    		html+="  <li class='am-active'>";
			   			html+="      <a href='#' class=''>"+label[j]+"</a>";
			    		html+="  </li>";
			    	}
			    }
			    html+="                    </ul>";
			    html+="                </div>";
			    html+="                <div class='font-color-16'>培训方向："+jsonCounselor.studylist[i].studyDirection+"</div>";
			    html+="            </div>";
			    html+="        </div>";
			    html+="        <div class='am-g bg-gray am-margin-top-sm  am-padding-bottom-sm  prelative'>";
			    html+="            <i class='icon_12s'></i>";
			    html+="            <div class='am-u-sm-12  font-15 '>";
			    html+="                <div class=' font-color-13  am-padding-top-sm  box'>";
			    html+="                    <div class='width-50px'><i class='icon_28'></i></div>";
			    html+="                    <div class='box-1'><span>人数上限：</span><span>"+jsonCounselor.studylist[i].maxStudent+"</span><span class='font-color-16'>(已报"+jsonCounselor.studylist[i].signStudent+")</span>";
			    html+="                    </div>";
			    html+="                </div>";
			    html+="            </div>";
			    html+="            <div class='am-u-sm-12  font-15'>";
			    html+="                <div class=' font-color-13  am-padding-top-sm  box'>";
			    html+="                    <div class='width-50px'><i class='icon_29'></i></div>";
			    html+="                    <div class='box-1'><span>培训时间："+jsonCounselor.studylist[i].startStudyStr+" -- "+jsonCounselor.studylist[i].endStudyStr+"</span></div>";
			    html+="                </div>";
			    html+="            </div>";
			    html+="        </div>";
			    html+="        <div class='am-g '>";
			    html+="            <div class='am-u-sm-6 padding-left-0'>";
			    html+="                <div class='btn-15 am-margin-top-sm'>";
			    html+="                    <span class='prelative am-margin-left-sm'> <i class='icon_25_1'></i>售价：&yen;"+jsonCounselor.studylist[i].studyPrice+"</span></div>";
			    html+="            </div>";
			    html+="            <div class='am-u-sm-6 padding-right-0'>";
				var peixunid=jsonCounselor.studylist[i].id;
			    hrefto="gotoConfirm?id="+peixunid;
			    
			    if(jsonCounselor.studylist[i].maxStudent==jsonCounselor.studylist[i].signStudent){
			    html+="                <div class='btn-5 am-margin-top-sm'>已报滿</div>";			    
			    }else{
			    html+="                <a href="+hrefto+" style='color:white'><div class='btn-5 am-margin-top-sm'>立即购买</div></a>";			    
			    }
			    html+="            </div>";
			    html+="        </div>";
			    html+="    </div>";
			   // html+="    </a>";
		    }
		 }

		$(".traincamp_list").html(html);

        $("#sort_price").add("#sort_date").on("click",function () {
            var orderBy="";         
            if ($(this).find(".icon-sort").hasClass("cur")) {
                $(this).find(".icon-sort").removeClass("cur");
                
                if($(this).text()=="时间"){
                	orderBy=2;
                }else{
                	orderBy=4;
                }
                
            }else{

                $(this).find(".icon-sort").addClass("cur");
                if($(this).text()=="时间"){
                	orderBy=1;
                }else{
                	orderBy=3;
                }
            }  
        var cans="studyType=2&orderBy="+orderBy;    
        if(""!=cityName_){
        	cans+="&cityName="+cityName_;
        } 
        var counselorList=$.ajax({url:"getStudyList?"+cans,async:false});
        var jsonCounselor=JSON.parse(counselorList.responseText);
        var html="";
        if(jsonCounselor.resultCode=="0"){
        	for(var i=0;i<jsonCounselor.studylist.length;i++){
        		//html+="<a href='https:www.baidu.com'>";
				html+="<div class='traincamp_item bg-white am-padding-sm border-1 am-margin-bottom-sm'>";
			    html+="        <div class='box' onclick=goPeiDesc("+jsonCounselor.studylist[i].id+")>";
			    html+="            <div><img class='img-70-70' src='"+jsonCounselor.studylist[i].studyUrl+"'></div>";
			    html+="            <div class='box-1 am-padding-left-sm'>";
			    html+="                <div class='font-color-13 font-bold font-16 word-space-2' onclick='goPeiDesc("+jsonCounselor.studylist[i].id+")'>"+jsonCounselor.studylist[i].studyTitle+"</div>";
			    html+="                <div class=''>";
			    html+="                    <ul class='am-pagination am-pagination-default' >";
			    if(null!=jsonCounselor.studylist[i].studyLabel && ""!=jsonCounselor.studylist[i].studyLabel){
			    	var studyLabel=jsonCounselor.studylist[i].studyLabel;
			    	var label=studyLabel.split(",");
			    	for(var j=0;j<label.length;j++){
			    		html+="  <li class='am-active'>";
			   			html+="      <a href='#' class=''>"+label[j]+"</a>";
			    		html+="  </li>";
			    	}
			    }
			    html+="                    </ul>";
			    html+="                </div>";
			    html+="                <div class='font-color-16'>培训方向："+jsonCounselor.studylist[i].studyDirection+"</div>";
			    html+="            </div>";
			    html+="        </div>";
			    html+="        <div class='am-g bg-gray am-margin-top-sm  am-padding-bottom-sm  prelative'>";
			    html+="            <i class='icon_12s'></i>";
			    html+="            <div class='am-u-sm-12  font-15 '>";
			    html+="                <div class=' font-color-13  am-padding-top-sm  box'>";
			    html+="                    <div class='width-50px'><i class='icon_28'></i></div>";
			    html+="                    <div class='box-1'><span>人数上限：</span><span>"+jsonCounselor.studylist[i].maxStudent+"</span><span class='font-color-16'>(已报"+jsonCounselor.studylist[i].signStudent+")</span>";
			    html+="                    </div>";
			    html+="                </div>";
			    html+="            </div>";
			    html+="            <div class='am-u-sm-12  font-15'>";
			    html+="                <div class=' font-color-13  am-padding-top-sm  box'>";
			    html+="                    <div class='width-50px'><i class='icon_29'></i></div>";
			    html+="                    <div class='box-1'><span>培训时间："+jsonCounselor.studylist[i].startStudyStr+" -- "+jsonCounselor.studylist[i].endStudyStr+"</span></div>";
			    html+="                </div>";
			    html+="            </div>";
			    html+="        </div>";
			    html+="        <div class='am-g '>";
			    html+="            <div class='am-u-sm-6 padding-left-0'>";
			    html+="                <div class='btn-15 am-margin-top-sm'>";
			    html+="                    <span class='prelative am-margin-left-sm'> <i class='icon_25_1'></i>售价：&yen;"+jsonCounselor.studylist[i].studyPrice+"</span></div>";
			    html+="            </div>";
			    html+="            <div class='am-u-sm-6 padding-right-0'>";
			    var peixunid=jsonCounselor.studylist[i].id;
			    hrefto="gotoConfirm?id="+peixunid;
			    if(jsonCounselor.studylist[i].maxStudent==jsonCounselor.studylist[i].signStudent){
			    html+="                <div class='btn-5 am-margin-top-sm'>已报滿</div>";			    
			    }else{
			    html+="                <a href="+hrefto+" style='color:white'><div class='btn-5 am-margin-top-sm'>立即购买</div></a>";			    
			    }
			    html+="            </div>";
			    html+="        </div>";
			    html+="    </div>";
			   // html+="    </a>";
		    }
		 }

		$(".traincamp_list").html(html);
            
            
        });

        $("#txtsearch").on("keyup",function(){
          if($(this).val()==""){
            $(".icon_14").addClass("am-hide");
          }else{
              $(".icon_14").removeClass("am-hide");
          }
        });
        
        $("#soso").click(function () {
		var txtsearch=$("#txtsearch").val();

		var counselorList=$.ajax({url:"getStudyList?studyType=2&txtsearch="+txtsearch,async:false});
        var jsonCounselor=JSON.parse(counselorList.responseText);
        
        var html="";
        if(jsonCounselor.resultCode=="0"){
        	for(var i=0;i<jsonCounselor.studylist.length;i++){
        		//html+="<a href='https:www.baidu.com'>";
				html+="<div class='traincamp_item bg-white am-padding-sm border-1 am-margin-bottom-sm'>";
			    html+="       <div class='box' onclick=goPeiDesc("+jsonCounselor.studylist[i].id+")>";
			    html+="            <div><img class='img-70-70' src='"+jsonCounselor.studylist[i].studyUrl+"'></div>";
			    html+="            <div class='box-1 am-padding-left-sm'>";
			    html+="                <div class='font-color-13 font-bold font-16 word-space-2' onclick='goPeiDesc("+jsonCounselor.studylist[i].id+")'>"+jsonCounselor.studylist[i].studyTitle+"</div>";
			    html+="                <div class=''>";
			    html+="                    <ul class='am-pagination am-pagination-default' >";
			    if(null!=jsonCounselor.studylist[i].studyLabel && ""!=jsonCounselor.studylist[i].studyLabel){
			    	var studyLabel=jsonCounselor.studylist[i].studyLabel;
			    	var label=studyLabel.split(",");
			    	for(var j=0;j<label.length;j++){
			    		html+="  <li class='am-active'>";
			   			html+="      <a href='#' class=''>"+label[j]+"</a>";
			    		html+="  </li>";
			    	}
			    }
			    html+="                    </ul>";
			    html+="                </div>";
			    html+="                <div class='font-color-16'>培训方向："+jsonCounselor.studylist[i].studyDirection+"</div>";
			    html+="            </div>";
			    html+="        </div>";
			    html+="        <div class='am-g bg-gray am-margin-top-sm  am-padding-bottom-sm  prelative'>";
			    html+="            <i class='icon_12s'></i>";
			    html+="            <div class='am-u-sm-12  font-15 '>";
			    html+="                <div class=' font-color-13  am-padding-top-sm  box'>";
			    html+="                    <div class='width-50px'><i class='icon_28'></i></div>";
			    html+="                    <div class='box-1'><span>人数上限：</span><span>"+jsonCounselor.studylist[i].maxStudent+"</span><span class='font-color-16'>(已报"+jsonCounselor.studylist[i].signStudent+")</span>";
			    html+="                    </div>";
			    html+="                </div>";
			    html+="            </div>";
			    html+="            <div class='am-u-sm-12  font-15'>";
			    html+="                <div class=' font-color-13  am-padding-top-sm  box'>";
			    html+="                    <div class='width-50px'><i class='icon_29'></i></div>";
			    html+="                    <div class='box-1'><span>培训时间："+jsonCounselor.studylist[i].startStudyStr+" -- "+jsonCounselor.studylist[i].endStudyStr+"</span></div>";
			    html+="                </div>";
			    html+="            </div>";
			    html+="        </div>";
			    html+="        <div class='am-g '>";
			    html+="            <div class='am-u-sm-6 padding-left-0'>";
			    html+="                <div class='btn-15 am-margin-top-sm'>";
			    html+="                    <span class='prelative am-margin-left-sm'> <i class='icon_25_1'></i>售价：&yen;"+jsonCounselor.studylist[i].studyPrice+"</span></div>";
			    html+="            </div>";
			    html+="            <div class='am-u-sm-6 padding-right-0'>";
			    
			    var peixunid=jsonCounselor.studylist[i].id;
			    hrefto="gotoConfirm?id="+peixunid;
			    if(jsonCounselor.studylist[i].maxStudent==jsonCounselor.studylist[i].signStudent){
			    html+="                <div class='btn-5 am-margin-top-sm'>已报滿</div>";			    
			    }else{
			    html+="                <a href="+hrefto+" style='color:white'><div class='btn-5 am-margin-top-sm'>立即购买</div></a>";			    
			    }
			    html+="            </div>";
			    html+="        </div>";
			    html+="    </div>";
			   // html+="    </a>";
		    }
		 }

		$(".traincamp_list").html(html);
		});
    });
</script>
<script>
    $(function () {
        // 城市选择
        $("[data-node='city']").find(" li").click(function () {
            $("[data-node='city']").find(" li").removeClass("selected");
            $(this).addClass("selected");
            $("#span_city").text($(this).text().substring(0, 2));
        var cityName=$(this).text().substring(0, 2);
        cityName_=cityName;
        var counselorList=$.ajax({url:"getStudyList?studyType=2&cityName="+cityName,async:false});
        var jsonCounselor=JSON.parse(counselorList.responseText);
        
        var html="";
        if(jsonCounselor.resultCode=="0"){
        	for(var i=0;i<jsonCounselor.studylist.length;i++){
        		//html+="<a href='https:www.baidu.com'>";
				html+="<div class='traincamp_item bg-white am-padding-sm border-1 am-margin-bottom-sm'>";
			    html+="       <div class='box' onclick=goPeiDesc("+jsonCounselor.studylist[i].id+")>";
			    html+="            <div><img class='img-70-70' src='"+jsonCounselor.studylist[i].studyUrl+"'></div>";
			    html+="            <div class='box-1 am-padding-left-sm'>";
			    html+="                <div class='font-color-13 font-bold font-16 word-space-2' onclick='goPeiDesc("+jsonCounselor.studylist[i].id+")'>"+jsonCounselor.studylist[i].studyTitle+"</div>";
			    html+="                <div class=''>";
			    html+="                    <ul class='am-pagination am-pagination-default' >";
			    if(null!=jsonCounselor.studylist[i].studyLabel && ""!=jsonCounselor.studylist[i].studyLabel){
			    	var studyLabel=jsonCounselor.studylist[i].studyLabel;
			    	var label=studyLabel.split(",");
			    	for(var j=0;j<label.length;j++){
			    		html+="  <li class='am-active'>";
			   			html+="      <a href='#' class=''>"+label[j]+"</a>";
			    		html+="  </li>";
			    	}
			    }
			    html+="                    </ul>";
			    html+="                </div>";
			    html+="                <div class='font-color-16'>培训方向："+jsonCounselor.studylist[i].studyDirection+"</div>";
			    html+="            </div>";
			    html+="        </div>";
			    html+="        <div class='am-g bg-gray am-margin-top-sm  am-padding-bottom-sm  prelative'>";
			    html+="            <i class='icon_12s'></i>";
			    html+="            <div class='am-u-sm-12  font-15 '>";
			    html+="                <div class=' font-color-13  am-padding-top-sm  box'>";
			    html+="                    <div class='width-50px'><i class='icon_28'></i></div>";
			    html+="                    <div class='box-1'><span>人数上限：</span><span>"+jsonCounselor.studylist[i].maxStudent+"</span><span class='font-color-16'>(已报"+jsonCounselor.studylist[i].signStudent+")</span>";
			    html+="                    </div>";
			    html+="                </div>";
			    html+="            </div>";
			    html+="            <div class='am-u-sm-12  font-15'>";
			    html+="                <div class=' font-color-13  am-padding-top-sm  box'>";
			    html+="                    <div class='width-50px'><i class='icon_29'></i></div>";
			    html+="                    <div class='box-1'><span>培训时间："+jsonCounselor.studylist[i].startStudyStr+" -- "+jsonCounselor.studylist[i].endStudyStr+"</span></div>";
			    html+="                </div>";
			    html+="            </div>";
			    html+="        </div>";
			    html+="        <div class='am-g '>";
			    html+="            <div class='am-u-sm-6 padding-left-0'>";
			    html+="                <div class='btn-15 am-margin-top-sm'>";
			    html+="                    <span class='prelative am-margin-left-sm'> <i class='icon_25_1'></i>售价：&yen;"+jsonCounselor.studylist[i].studyPrice+"</span></div>";
			    html+="            </div>";
			    html+="            <div class='am-u-sm-6 padding-right-0'>";
				var peixunid=jsonCounselor.studylist[i].id;
			    hrefto="gotoConfirm?id="+peixunid;
			    if(jsonCounselor.studylist[i].maxStudent==jsonCounselor.studylist[i].signStudent){
			    html+="                <div class='btn-5 am-margin-top-sm'>已报滿</div>";			    
			    }else{
			    html+="                <a href="+hrefto+" style='color:white'><div class='btn-5 am-margin-top-sm'>立即购买</div></a>";			    
			    }
			    html+="            </div>";
			    html+="        </div>";
			    html+="    </div>";
			   // html+="    </a>";
		    }
		 }

		$(".traincamp_list").html(html);
            
        });
    });
</script>
</body>
</html>